package com.jch.gettingstarted;

import com.jch.gettingstarted.handler.ReadHandler;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;

public class DemoChannelInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        System.out.println("连接信息报告开始");
        System.out.println("有一个客户端连接到当前服务端");
        System.out.println("IP：" + socketChannel.localAddress().getHostString());
        System.out.println("PORT：" + socketChannel.localAddress().getPort());
        System.out.println("连接信息报告完成！");

        // 读取数据
        socketChannel.pipeline().addLast(new ReadHandler());
    }
}
